/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jp.co.irep.juten.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author toan_nguyen
 */
@Entity
@Table(name = "place_product")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PlaceProduct.findAll", query = "SELECT p FROM PlaceProduct p"),
    @NamedQuery(name = "PlaceProduct.findByPlaceId", query = "SELECT p FROM PlaceProduct p WHERE p.placeProductPK.placeId = :placeId"),
    @NamedQuery(name = "PlaceProduct.findByProductId", query = "SELECT p FROM PlaceProduct p WHERE p.placeProductPK.productId = :productId")})
public class PlaceProduct implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PlaceProductPK placeProductPK;

    public PlaceProduct() {
    }

    public PlaceProduct(PlaceProductPK placeProductPK) {
        this.placeProductPK = placeProductPK;
    }

    public PlaceProduct(int placeId, int productId) {
        this.placeProductPK = new PlaceProductPK(placeId, productId);
    }

    public PlaceProductPK getPlaceProductPK() {
        return placeProductPK;
    }

    public void setPlaceProductPK(PlaceProductPK placeProductPK) {
        this.placeProductPK = placeProductPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (placeProductPK != null ? placeProductPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlaceProduct)) {
            return false;
        }
        PlaceProduct other = (PlaceProduct) object;
        if ((this.placeProductPK == null && other.placeProductPK != null) || (this.placeProductPK != null && !this.placeProductPK.equals(other.placeProductPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jp.co.irep.tech.juten.jpa.entity.PlaceProduct[ placeProductPK=" + placeProductPK + " ]";
    }
    
}
